package com.sc.nft.dao;


import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.sc.nft.entity.AdministrativeArea;
import com.sc.nft.mapper.AdministrativeAreaMapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Repository;

/**
 * @author wangweicheng
 */
@Slf4j
@Repository
public class AdministrativeAreaDao extends ServiceImpl<AdministrativeAreaMapper, AdministrativeArea> {

    public AdministrativeArea administrationCode(String idCardSix) {
        LambdaQueryWrapper<AdministrativeArea> wrapper = Wrappers.lambdaQuery();
        wrapper.eq(AdministrativeArea::getCode, idCardSix);
        wrapper.last("limit 1");
        return getOne(wrapper);
    }

    public AdministrativeArea administrationRegionId(Long regionId) {
        LambdaQueryWrapper<AdministrativeArea> wrapper = Wrappers.lambdaQuery();
        wrapper.eq(AdministrativeArea::getRegionId, regionId);
        wrapper.last("limit 1");
        return getOne(wrapper);
    }


}
